<?php

namespace app\demo\controller;

use my\BaiduOcr;
use think\facade\Db;

class Baidu extends Base
{

    private function index() {
        $file = 'test.php';
//        $file = 'jiegeng.jpg';
        // 你的 APPID AK SK
        $client = new BaiduOcr();
        $res = $client->getTextFromImage($file);
        $str = '';
        if(isset($res['words_result'])) {
            // 正确处理
            foreach ($res['words_result'] as $row) {
                $str .= $row['words'];
            }
        }else if(isset($res['error_msg'])) {
            // 错误处理
            pp($res['error_msg']);
        }
        var_dump($str);
    }





}
